﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace SlamCms.Configuration
{
	public class SolutionConfigurationEnvironmentDictionary : Dictionary<string, SolutionConfigurationEnvironment>
	{
		public SolutionConfigurationEnvironmentDictionary(SolutionConfiguration configuration)
		{
			configuration["Environments.Environment"].ForEach(e =>
				this.Add(e["Name"], new SolutionConfigurationEnvironment(e["Name"], e["AdminUrl"], e["FrontEndUrl"], e["OtherUrls"], String.IsNullOrEmpty(e["Production"]) ? false : bool.Parse(e["Production"]))));
		}
	}

	public class SolutionConfigurationEnvironment
	{
		public string AdminUrl
		{
			get;
			set;
		}

		public string FrontEndUrl
		{
			get;
			set;
		}

		public string Name
		{
			get;
			set;
		}

		public string OtherUrls
		{
			get;
			set;
		}

		public bool Production
		{
			get;
			set;
		}

		public SolutionConfigurationEnvironment(string name, string adminUrl, string frontEndUrl, string otherUrls, bool production)
		{
			Name = name;
			AdminUrl = adminUrl;
			FrontEndUrl = frontEndUrl;
			OtherUrls = otherUrls;
			Production = production;
		}
	}
}
